<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <link rel="stylesheet" href="./layui/css/layui.css">
</head>
<body>
<h2 align="center">用户注册</h2>
<form class="layui-form">
<div style="width: 100%;height:300px; border:1px solid red">
    <br>
    <input type="hidden" id="token" value="">
    <div class="layui-form-item">
        <label class="layui-form-label">呢称</label>
        <div class="layui-input-inline">
            <input type="text" name="nickname" required  lay-verify="required" placeholder="请输入呢称" autocomplete="off" class="layui-input" >
        </div>

        <label class="layui-form-label">用户名</label>
        <div class="layui-input-inline">
            <input type="text" name="name" required lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
        </div>

        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">数字字母下划线</div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">个人简介</label>
        <div class="layui-input-block">
            <textarea name="inrod" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <!--<button class="layui-btn layui-btn-warm"  style="margin: 0 auto;">注册</button>-->
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="sub">注册</button>
        </div>
    </div>
</div>
</form>
</body>
</html>
<script src="./layui/layui.js"></script>
<script>

    /**
     * 发送ajax请求
     */
    layui.use(['jquery','layer',"form"], function(){
        var $ = layui.jquery, layer = layui.layer, form = layui.form;
        form.on('submit(sub)', function(data){
            console.log(data.field);
            $.ajax({
                url : "./deal.php?action=register",
                type : "post",
                data : data.field,
                dataType : "json",
                success : function(res){
                    layer.msg(res.msg);
                    if(res.code == 200){
                        window.setTimeout("window.location='login.html'",2000);
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        })
    });



</script>